FTP

Förkortningar

  • FTP - File Transfer Protocol
  • lcd - local change directory

  • ABOR - abort a file transfer
  • CWD - change working directory
  • DELE - delete a remote file
  • LIST - list remote files
  • MDTM - return the modification time of a file
  • MKD - make a remote directory
  • NLST - name list of remote directory
  • PASS - send password
  • PASV - enter passive mode
  • PORT - open a data port
  • PWD - print working directory
  • QUIT - terminate the connection
  • RETR - retrieve a remote file
  • RMD - remove a remote directory
  • RNFR - rename from
  • RNTO - rename to
  • SITE - site-specific commands
  • SIZE - return the size of a file
  • STOR - store a file on the remote host
  • TYPE - set transfer type
  • USER - send username

  • ACCT* - send account information
  • APPE - append to a remote file
  • CDUP - CWD to the parent of the current directory
  • HELP - return help on using the server
  • MODE - set transfer mode
  • NOOP - do nothing
  • REIN* - reinitialize the connection
  • STAT - return server status
  • STOU - store a file uniquely
  • STRU - set file transfer structure
  • SYST - return system type

FTP är ett interface för användare som ARPANET har standardiserat. Förkortningen står för File Transfer Protocol. FTP används för att överföra filer till och från en server med hjälp av ett nätverk.

FTP gör det möjligt att föra över filer från en maskin till en annan med hjälp av ett nätverk. FTP är användbart eftersom det gör det möjligt för dig att lagra eller ta emot filer från vilken dator som helst i världen. Det finns många olika klienter, eller program för FTP. Det första och det som förekommer mest är textbaserat och finns alltid på system som baseras på UNIX.

Citat

SSH File Transfer Protocol (SFTP) är ett filöverföringsprotokoll som oftast använder sig av SSH-2 som databärare dock skulle det kunna använda andra protokoll så som TLS. SFTP är inte att förväxla med SSL File Transfer Protocol som är säker FTP med SSL.

Protokoll

ftp://

Port

21

RFC

959 Logotyp för FTPManager Logotyp för FZ - Filezilla Ikon med logotyp för Coda Logotyp för Transmit Logotyp för Transmit Ny logotyp för Cyberduck Logotyp för Cyberduck

Program

Version av FTP

ftp --version

Vilken FTP?

which ftp

Sökväg

?

Hämta FTP för Mac med Homebrew i UNIX

brew install inetutils

Anslut med UNIX

ftp ftp.example.com

Anslut till Loopia med UNIX

ftp ftpcluster.loopia.se

UNIX

pwd cd ls dir

bin

Toggle Interactive mode

prompt

Progress bar för upp- och nedladdning

hash

Default mapp

lcd

Återgå till UNIX

!

Ladda ner

En fil

get smile.png

Flera filer

mget smile.png house.jpg

Ladda upp

En fil

put smile.png

Flera filer

mput smile.png house.jpg

Flytta

rename smile.png smiley.png

Exit

bye exit

FTP raw

quote

Common commands

  • ABOR - abort a file transfer
  • CWD - change working directory
  • DELE - delete a remote file
  • LIST - list remote files
  • MDTM - return the modification time of a file
  • MKD - make a remote directory
  • NLST - name list of remote directory
  • PASS - send password
  • PASV - enter passive mode
  • PORT - open a data port
  • PWD - print working directory
  • QUIT - terminate the connection
  • RETR - retrieve a remote file
  • RMD - remove a remote directory
  • RNFR - rename from
  • RNTO - rename to
  • SITE - site-specific commands
  • SIZE - return the size of a file
  • STOR - store a file on the remote host
  • TYPE - set transfer type
  • USER - send username

Less common commands

  • ACCT* - send account information
  • APPE - append to a remote file
  • CDUP - CWD to the parent of the current directory
  • HELP - return help on using the server
  • MODE - set transfer mode
  • NOOP - do nothing
  • REIN* - reinitialize the connection
  • STAT - return server status
  • STOU - store a file uniquely
  • STRU - set file transfer structure
  • SYST - return system type

FTP using cURL (länk)

Download a file using FTP

curl ftp://myftpsite.com/mp3/mozart_piano_sonata.zip --user myname:mypassword -o mozart_piano_sonata.zip

Upload a file using FTP

curl -T koc_dance.mp3 ftp://myftpsite.com/mp3/ --user myname:mypassword

List files in sub directories

curl ftp://myftpsite.com/mp3/ --user myname:mypassword

List only directories, silent the curl progress bar, and use grep to filter

curl ftp://myftpsite.com --user myname:mypassword -s | grep ^d

Remove files using FTP

This is a bit tricky, because curl do not support that by default, well anyway, you can make use of -X and pass in the REAL FTP command. (Check out a list of FTP service Command in rfc 959, under 4.1.3. FTP SERVICE COMMANDS)

curl ftp://myftpsite.com/ -X 'DELE mp3/koc_dance.mp3' --user myname:mypassword

Caution: Make sure you are know what are you deleting! It will not prompts ‘Are you sure?’ confirmation.

SSH

Liknande

Hämta fil med SFTP i PHP

$connection = ssh2_connect($host, $port); ssh2_auth_password($connection, $user, $password); $sftp = ssh2_sftp($connection); $stream = fopen('ssh2.sftp://' intval($sftp), $folder . $file, 'r'); Protokoll Arkiv

Externa länkar

Hjälp

Available commands: bye Quit sftp cd path Change remote directory to 'path' chgrp [-h] grp path Change group of file 'path' to 'grp' chmod [-h] mode path Change permissions of file 'path' to 'mode' chown [-h] own path Change owner of file 'path' to 'own' df [-hi] [path] Display statistics for current directory or filesystem containing 'path' exit Quit sftp get [-afpR] remote [local] Download file help Display this help text lcd path Change local directory to 'path' lls [ls-options [path]] Display local directory listing lmkdir path Create local directory ln [-s] oldpath newpath Link remote file (-s for symlink) lpwd Print local working directory ls [-1afhlnrSt] [path] Display remote directory listing lumask umask Set local umask to 'umask' mkdir path Create remote directory progress Toggle display of progress meter put [-afpR] local [remote] Upload file pwd Display remote working directory quit Quit sftp reget [-fpR] remote [local] Resume download file rename oldpath newpath Rename remote file reput [-fpR] local [remote] Resume upload file rm path Delete remote file rmdir path Remove remote directory symlink oldpath newpath Symlink remote file version Show SFTP version !command Execute 'command' in local shell ! Escape to local shell ? Synonym for help